package com.grm.juc.j01_xianchengjichu;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;

/**
 * desc: 创建线程方式3_实现Callable接口
 *
 * @author gaorimao
 * @since 2022-09-01 10:50:00
 */
public class MyCallable {
    public static void main(String[] args) {
        FutureTask<String> futureTask = new FutureTask<>(() -> "success");
        new Thread(futureTask).start();
        try {
            String result = futureTask.get();
            System.out.println(result);
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }
    }
}
